/**
 * Initialize your data structure here. Set the size of the deque to be k.
 * @param {number} k
 */
var MyCircularDeque = function(k) {
    // 队列的容量
    this.max = k;
    // 使用数组存放队列元素 初始的时候值都为-1  取值的时候直接返回
    this.queue = new Array(k).fill(-1)
    // 队列的头指针 即队列头元素的位置
    this.head = 0
    // 队列的尾指针 即尾部要插入元素的位置 也就是队列的尾元素的位置+1
    this.tail = 0
};

/**
 * Adds an item at the front of Deque. Return true if the operation is successful.
 * @param {number} value
 * @return {boolean}
 */
//将一个元素添加到双端队列头部。 如果操作成功返回 true
MyCircularDeque.prototype.insertFront = function(value) {
    // 判断队列是否已满
    if (this.isFull()) {
        return false
    }
    // 从头部插入元素 要先将头指针向前移动一位
    this.head = this.reduceIndex(this.head);
};

/**
 * Adds an item at the rear of Deque. Return true if the operation is successful.
 * @param {number} value
 * @return {boolean}
 */
//将一个元素添加到双端队列尾部。如果操作成功返回 true
MyCircularDeque.prototype.insertLast = function(value) {

};

/**
 * Deletes an item from the front of Deque. Return true if the operation is successful.
 * @return {boolean}
 */
//从双端队列头部删除一个元素。 如果操作成功返回 true
MyCircularDeque.prototype.deleteFront = function() {

};

/**
 * Deletes an item from the rear of Deque. Return true if the operation is successful.
 * @return {boolean}
 */
//从双端队列尾部删除一个元素。如果操作成功返回 true
MyCircularDeque.prototype.deleteLast = function() {

};

/**
 * Get the front item from the deque.
 * @return {number}
 */
//从双端队列头部获得一个元素。如果双端队列为空，返回 -1
MyCircularDeque.prototype.getFront = function() {

};

/**
 * Get the last item from the deque.
 * @return {number}
 */
//获得双端队列的最后一个元素。 如果双端队列为空，返回 -1
MyCircularDeque.prototype.getRear = function() {

};

/**
 * Checks whether the circular deque is empty or not.
 * @return {boolean}
 */
//检查双端队列是否为空
MyCircularDeque.prototype.isEmpty = function() {

};

/**
 * Checks whether the circular deque is full or not.
 * @return {boolean}
 */
//检查双端队列是否满了
MyCircularDeque.prototype.isFull = function() {

};

/**
 * Your MyCircularDeque object will be instantiated and called as such:
 * var obj = new MyCircularDeque(k)
 * var param_1 = obj.insertFront(value)
 * var param_2 = obj.insertLast(value)
 * var param_3 = obj.deleteFront()
 * var param_4 = obj.deleteLast()
 * var param_5 = obj.getFront()
 * var param_6 = obj.getRear()
 * var param_7 = obj.isEmpty()
 * var param_8 = obj.isFull()
 */